<%@page import="com.googlecode.contests_repo.core.model.DownloadUtils"%>
<%@page import="com.googlecode.contests_repo.core.config.ConfigurationManager" %>
<%@page import="java.io.File"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@include file='header.jsp'%>
	<%
	    String seriesTitle = request.getParameter("series");
	    String contestTitle = request.getParameter("contest");
	    String problemTitle = request.getParameter("problem");
	    String resourceFolder = request.getParameter("folder");
	    String fromJsp = request.getParameter("from");
	    String filePath = ConfigurationManager.getInstance().getRepoRoot();
	    String backLink = fromJsp+".jsp?";
	    if(seriesTitle != null){
			filePath = filePath + File.separator + seriesTitle;
			backLink = backLink + "series=" + seriesTitle;
			if(contestTitle != null){
				filePath = filePath + File.separator + contestTitle;
				backLink = backLink + "&contest=" + contestTitle;
				if(problemTitle != null){
					filePath = filePath + File.separator + problemTitle;
					backLink = backLink + "&problem=" + problemTitle;
			    }
		    }
	    }
	    filePath = filePath + File.separator + resourceFolder;
		DownloadUtils.downloadFolder(filePath,resourceFolder+".zip",response);
		response.sendRedirect(backLink);
	%>
</body>
</html>
